package Meituan;

import java.io.FileInputStream;

/**
 * 解析二进制文件
 * @author: leiwenkang02@meituan.com
 * @date: 2018/5/24
 * @time: 16:01
 */
public class QuakeTest {
    public static void main(String[] args) {
        //qa单个商品
        String name = "mtthrift_com.sankuai.meituan.sc.thrift.serivce.BannerIface_get2ndNewBanners_20190617163453 (1).tf";

        //线上阳光超市新世纪店多个商品
//        String name = "mtthrift_com.sankuai.meituan.waimai.thrift.activity.iface.WmActivityNBizThriftIface_getActivitySelectResult_20180529102206.tf";
        String fileName = "/Users/leiwenkang/Downloads/" + name;
        parseByteFile(fileName);
    }

    public static void parseByteFile(String fileName) {
        FileInputStream input = null;
        try {
            input = new FileInputStream(fileName);
            byte[] buffer = new byte[1024];
            while (true) {
                int len = input.read(buffer);
                if (len == -1) {
                    break;
                }
                String str = new String(buffer, 0, len);
                System.out.println(str);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            try {
                input.close();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
